﻿using M_Manufacture.API.Application.Command.ProductionPlanCommand;
using M_Manufacture.Repository.Interface;
using MediatR;

namespace M_Manufacture.API.Application.CommandHandlers.ProductionPlanCommandHandler
{
    /// <summary>
    /// 作废
    /// </summary>
    public class ZuoFeiCommandHandler : IRequestHandler<ZuoFeiCommand, int>
    {
        /// <summary>
        /// 生产计划仓储接口
        /// </summary>
        protected readonly IProductionPlanRepository _productionPlanRepository;

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="productionPlanRepository">生产计划仓储接口</param>
        public ZuoFeiCommandHandler(IProductionPlanRepository productionPlanRepository)
        {
           _productionPlanRepository = productionPlanRepository;
        }
        public async Task<int> Handle(ZuoFeiCommand request, CancellationToken cancellationToken)
        {
            var ss = await _productionPlanRepository.GetModelsAsync(request.ProductionPlanId);
            ss.IsDeleted=true;
            return await _productionPlanRepository.UpdateAsync(ss);
        }
    }
}
